/*
题目描述

定义有理数类（分母不为0的分数，分子分母均为整数）Rational，实现相应操作符的重载。

（1）定义私有数据成员：分子int iUp; 分母 int iDown。

（2）定义私有成员函数：void Reduce() 和 int Gcd(int l, int r)，分别用于有理数的约简和求两个整数的最大公约数。
其中，在约简时需要求取分子与分母的最大公约数。

（3）定义构造函数，在构造函数体内可调用Reduce对有理数进行约简。

（4）将 负号 - 和 赋值运算符 = 重载为公有成员函数，分别用于求有理数的负数和赋值。

（5）将前置++、前置--、后置++、后置--重载为公有成员函数，实现有理数自增1或自减1。

（6）将+、-、*、/重载为友员函数，实现有理数的加减乘除。

（7）将<、<=、>、>=重载为友员函数，实现有理数的大小关系比较。

（8）重载流插入符<<和流提取符>>，分别用于有理数的输出和输入。其中，输出格式为“分子/分母”，若为整数，则直接输出整数。

 

在main函数中，根据输入的分子和分母定义两个有理数对象a和b。
再定义几个有理数对象分别用于表示a和b的加、减、乘、除、前置自增a、前置自减a、后置自增a、后置自减a，
并依次各个对象的结果。最后依次用<、<=、>、>=比较a和b的大小关系，并依次输出比较结果（true或false）。
输入

两个有理数a和b的的分子和分母
输出

有理数a和b的加、减、乘、除以及前置自增a、前置自减a、后置自增a、后置自减a

有理数a和b的<、<=、>、>=的结果
样例输入

4 3
3 2

样例输出

a+b: 17/6
a-b: -1/6
a*b: 2
a/b: 8/9
-a: -4/3
++a: 7/3
--a: 4/3
a++: 4/3
a--: 7/3
a<b: true
a<=b: true
a>b: false
a>=b: false
*/
#include <iostream>

using namespace std;

class Rational
{
public:
    Rational(){}
    Rational(int Up, int Down);
    ~Rational(){}
    friend Rational operator+(const Rational& fra1, const Rational& fra2);
    friend Rational operator-(const Rational& fra1, const Rational& fra2);
    friend Rational operator*(const Rational& fra1, const Rational& fra2);
    friend Rational operator/(const Rational& fra1, const Rational& fra2);
    Rational operator-();
    Rational operator=(const Rational& fraction);
    Rational operator++();
    Rational operator++(int Dummy);
    Rational operator--();
    Rational operator--(int Dummy);
    friend bool operator<(const Rational& fra1, const Rational& fra2);
    friend bool operator<=(const Rational& fra1, const Rational& fra2);
    friend bool operator>(const Rational& fra1, const Rational& fra2);
    friend bool operator>=(const Rational& fra1, const Rational& fra2);
    friend ostream& operator<<(ostream& out, const Rational& fraction);
    friend istream& operator>>(istream& in, Rational& fraction);
private:
    int iUp;
    int iDown;
    void Reduce();
    int Gcd(int l, int r);
};

int main()

{
    int iUp1, iDown1, iUp2, iDown2;
    cin >> iUp1 >> iDown1 >> iUp2 >> iDown2;
    Rational a(iUp1, iDown1), b(iUp2, iDown2);

    cout << "a+b: " << a + b;
    cout << "a-b: " << a - b;
    cout << "a*b: " << a * b;
    cout << "a/b: " << a / b;
    cout << "-a: " << -a;
    cout << "++a: " << ++a;
    cout << "--a: " << --a;
    cout << "a++: " << a++;
    cout << "a--: " << a--;

    cout << "a<b: ";
    if (a < b)  cout << "true" << endl;
    else cout << "false" << endl;

    cout << "a<=b: ";
    if (a <= b) cout << "true" << endl;
    else cout << "false" << endl;

    cout << "a>b: ";
    if (a > b) cout << "true" << endl;
    else cout << "false" << endl;

    cout << "a>=b: ";
    if (a >= b) cout << "true" << endl; 
    else cout << "false" << endl;

    return 0;
}

void Rational::Reduce()
{
    int gcd = abs(this->Gcd(iUp, iDown));
    this->iUp /= gcd;
    this->iDown /= gcd;
    if (iDown < 0) {
        this->iUp = -this->iUp;
        this->iDown = -this->iDown;
    }
}

int Rational::Gcd(int l, int r)
{
    if (!r) return l;
    else return Gcd(r, l % r);
}

Rational::Rational(int Up, int Down) : iUp(Up), iDown(Down)
{
    this->Reduce();
}

Rational Rational::operator-()
{
    Rational temp = *this;
    temp.iUp = -this->iUp;
    temp.iDown = this->iDown;
    return temp;
}

Rational Rational::operator=(const Rational& fraction)
{
    if (this == &fraction) return *this;
    this->iUp = fraction.iUp;
    this->iDown = fraction.iDown;
    return *this;
}

Rational Rational::operator++()
{
    this->iUp += this->iDown;
    return *this;

}

Rational Rational::operator++(int Dummy)
{
    Rational loc = *this;
    this->iUp += this->iDown;
    return loc;

}

Rational Rational::operator--()
{
    this->iUp -= this->iDown;
    return *this;
}

Rational Rational::operator--(int Dummy)
{
    Rational loc = *this;
    this->iUp -= this->iDown;
    return loc;
}

Rational operator+(const Rational& fra1, const Rational& fra2)
{
    int Up = fra1.iUp * fra2.iDown + fra2.iUp * fra1.iDown;
    int Down = fra1.iDown * fra2.iDown;
    return Rational(Up, Down);
}

Rational operator-(const Rational& fra1, const Rational& fra2)
{
    int Up = fra1.iUp * fra2.iDown - fra2.iUp * fra1.iDown;
    int Down = fra1.iDown * fra2.iDown;
    return Rational(Up, Down);
}

Rational operator*(const Rational& fra1, const Rational& fra2)
{
    int Up = fra1.iUp * fra2.iUp;
    int Down = fra1.iDown * fra2.iDown;
   return Rational(Up, Down);
}

Rational operator/(const Rational& fra1, const Rational& fra2)
{
    int Up = fra1.iUp * fra2.iDown;
    int Down = fra1.iDown * fra2.iUp;
    return Rational(Up, Down);
}

bool operator<(const Rational& fra1, const Rational& fra2)
{
    Rational fraction = fra1 - fra2;
    if (fraction.iUp < 0) return true;
    else return false;
}

bool operator<=(const Rational& fra1, const Rational& fra2)
{
    Rational fraction = fra1 - fra2;
    if (fraction.iUp <= 0) return true;
    else return false;
}

bool operator>(const Rational& fra1, const Rational& fra2)
{
    Rational fraction = fra1 - fra2;
    if (fraction.iUp > 0) return true;
    else return false;
}

bool operator>=(const Rational& fra1, const Rational& fra2)
{
    Rational fraction = fra1 - fra2;
    if (fraction.iUp >= 0) return true;
    else return false;
}

ostream& operator<<(ostream& out, const Rational& fraction)
{
    if (fraction.iUp % fraction.iDown == 0) {
        cout << fraction.iUp / fraction.iDown << endl;
    }
    else {
        cout << fraction.iUp << "/"
            << fraction.iDown << endl;
    }
    return out;
}

istream& operator>>(istream& in, Rational& fraction)
{
    cin >> fraction.iUp >> fraction.iDown;
    return in;
}

